package com.lvyq.myplayer.model.singer

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.lvyq.myplayer.model.index.IndexHotSongBean
import com.lvyq.myplayer.net.api.singerApiService
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.launch

/**
 * 文件描述：IndexZaiTingModel 热门单曲
 * 作者：lvyq
 * 创建时间：2025-04-08
 * 修改时间：2025-04-08
 */

class SingerSongModel : ViewModel() {
    // 初始化数据（带标记）
    private val _initialData = MutableLiveData<SingerSongBean>()
    val initialData: LiveData<SingerSongBean> = _initialData

    // 加载更多数据（带标记）
    private val _loadMoreData = MutableLiveData<SingerSongBean>()
    val loadMoreData: LiveData<SingerSongBean> = _loadMoreData

    fun page( id:Int,pageNum: Int,pageSize:Int){
        println("pageNum>>"+pageNum+">>pageSize>>"+pageSize)
        viewModelScope.launch {
            var response = singerApiService.page(id,pageNum,pageSize)
            if (response.isSuccessful){
                if (pageNum == 1) {
                    _initialData.value=response.body()
                } else {
                    _loadMoreData.value=response.body()
                }
            }
        }
    }
}